<template>
  <div>
    <!-- 新增修改表单 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="DialogFormVisibleCom" :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form ref="dataForm" :model="formSubmitDataCom" :rules="rules" label-position="right" label-width="120px"
               style="width: 90%; margin:10px auto;">

        <el-row :gutter="20">
          <el-col :span="12">
            <!-- productnamecn -->
            <el-form-item label="productnamecn：" prop="productnamecn">
              <el-input  v-model="formSubmitDataCom.productnamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- deptnamecn -->
            <el-form-item label="deptnamecn：" prop="deptnamecn">
              <el-input  v-model="formSubmitDataCom.deptnamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- bunamecn -->
            <el-form-item label="bunamecn：" prop="bunamecn">
              <el-input  v-model="formSubmitDataCom.bunamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- companynamecn -->
            <el-form-item label="companynamecn：" prop="companynamecn">
              <el-input  v-model="formSubmitDataCom.companynamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- pgnamecn -->
            <el-form-item label="pgnamecn：" prop="pgnamecn">
              <el-input  v-model="formSubmitDataCom.pgnamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- pgnamecn -->
            <el-form-item label="bsnamecn：" prop="bsnamecn">
              <el-input  v-model="formSubmitDataCom.bsnamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- ftpgnamecn -->
            <el-form-item label="ftpgnamecn：" prop="ftpgnamecn">
              <el-input  v-model="formSubmitDataCom.ftpgnamecn"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- usedamountbefore -->
            <el-form-item label="usedamountbefore：" prop="usedamountbefore">
              <el-input  v-model="formSubmitDataCom.usedamountbefore"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- usedamountafter -->
            <el-form-item label="usedamountafter：" prop="usedamountafter ">
              <el-input  v-model="formSubmitDataCom.usedamountafter"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- usedamountchange -->
            <el-form-item label="usedamountchange：" prop="usedamountchange ">
              <el-input  v-model="formSubmitDataCom.usedamountchange"  placeholder="Please select"></el-input>
            </el-form-item>
          </el-col>
          

        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button @click="resetFormData">
          重置
        </el-button>
        <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
          提交
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {
  name: 'submitForm',
  components: {},
  props: {
    dialogFormVisible: {
      type: Boolean,
      default: false
    },
    dialogStatus: {
      type: String,
    },

    formSubmitData: {
      is_vacation: '',
      type: Object,
      default: function () {
        return {}
      }
    },


  },
  // 定义属性
  data() {
    return {
      textMap: {
        update: '修改',
        create: '新增'
      },
      rules: {
        is_vacation: [{required: true, message: '必填', trigger: 'change'}],
      },
      isVacationOptions: [{
        value: '1',
        label: '是'
      }, {
        value: '0',
        label: '否'
      }]

    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {
    DialogFormVisibleCom: {
      get() {
        return this.dialogFormVisible
      },
      set(val) {
        this.$emit('update:dialogFormVisible', val)
      }
    },
    formSubmitDataCom: {
      get() {
        return this.formSubmitData
      },
      set(val) {
        this.$emit('update:formSubmitData', val)
      }
    }
  },
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    // 重置
    resetFormData() {
      this.$emit('resetFormDataEmit')
    },
    createData() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$emit('handleFromCreateDataEmit')
        }
      })
    },

    updateData() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$delete(this.formSubmitDataCom, "_XID");
          this.$delete(this.formSubmitDataCom, "pgid");
          this.$delete(this.formSubmitDataCom, "pgnamecn");
          this.$emit('handleFromUpdateDataEmit')
        }
      })
    },

  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {
  }, // 生命周期 - 创建之前
  beforeMount() {
  }, // 生命周期 - 挂载之前
  beforeUpdate() {
  }, // 生命周期 - 更新之前
  updated() {
  }, // 生命周期 - 更新之后
  beforeDestroy() {
  }, // 生命周期 - 销毁之前
  destroyed() {
  }, // 生命周期 - 销毁完成
  activated() {
  }, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='scss' scoped>

</style>